package br.ufpe.cin.msc.jrsj2.recommender;

public final class Message {

	public enum MessageType {
		PROGRAM_LIST, CLIENT_PROFILE, CLIENT_QUIT, UNDEFINED;
	}

	public static MessageType getMessageType(String message) {
		StringBuffer msgBuffer = new StringBuffer(message);
		String mainElement = msgBuffer.substring(1, msgBuffer.indexOf(">"));
		String strMsgType = mainElement.split(" ")[0];

		if (strMsgType.equals("program-list"))
			return MessageType.PROGRAM_LIST;
		else if (strMsgType.equals("client-profile"))
			return MessageType.CLIENT_PROFILE;
		else if (strMsgType.equals("client-quit"))
			return MessageType.CLIENT_QUIT;

		return MessageType.UNDEFINED;
	}

}
